/*
 * Copyright (c) 2001-2018 GuaHao.com Corporation Limited. All rights reserved.
 * This software is the confidential and proprietary information of GuaHao Company.
 * ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you entered into with GuaHao.com.
 *
 */
package com.bolt.convention.data.code;

/**
 * 验证相关的code
 */
public enum AuthCode implements ServiceCode {

    // invalid_scope:Invalid scope parameter in request
    // AUTH_0:在请求中存在无效的scope参数
    INVALID_SCOPE_PARAMETER("0", AUTH, "在请求中存在无效的scope参数"),
    // invalid_scope:Missing scope parameter in request
    // AUTH_1:在请求中scope参数丢失
    MISSING_SCOPE_PARAMETER("1", AUTH,"在请求中scope参数丢失"),
    // unauthorized_client
    // AUTH_2:不支持当前的授权方式
    UNAUTHORIZED_CLIENT("2", AUTH, "不支持当前的授权方式"),
    // access_denied:Authorization denied by user
    // AUTH_3:用户授权拒绝
    AUTHORIZATION_DENIED_BY_USER("3", AUTH, "用户授权拒绝"),
    // invalid_request:Missing code parameter in request
    // AUTH_4:code参数不能为空
    MISSING_CODE_PARAMETER("4", AUTH, "code参数不能为空"),
    // invalid_request:Missing redirect_uri parameter in request
    // AUTH_5:redirect_uri参数不能为空
    MISSING_REDIRECT_URI_PARAMETER("5", AUTH, "redirect_uri参数不能为空"),
    // invalid_request:Invalid redirect_uri parameter
    // AUTH_6: 无效的redirect_uri参数
    INVALID_REDIRECT_URI_PARAMETER("6", AUTH, "无效的redirect_uri参数"),
    // invalid_request:Invalid authorization code parameter
    // invalid_grant:Invalid code parameter in request
    // AUTH_7: 无效的授权码
    INVALID_AUTHORIZATION_CODE("7", AUTH, "无效的授权码"),
    // invalid_grant:Authorization code has expired
    // AUTH_8: 授权码已过期
    AUTHORIZATION_CODE_HAS_EXPIRED("8", AUTH, "授权码已过期"),
    // invalid_request:Missing username parameter in request
    // AUTH_9: username参数不能为空
    MISSING_USERNAME_PARAMETER("9", AUTH, "username参数不能为空"),
    // invalid_request:Missing password parameter in request
    // AUTH_10: password参数不能为空
    MISSING_PASSWORD_PARAMETER("10", AUTH, "password参数不能为空"),
    // invalid_request:Invalid refresh token
    // AUTH_11: 无效的refresh token
    INVALID_REFRESH_TOKEN("11", AUTH, "无效的refresh token"),
    // invalid_request:Missing refresh_token in request body
    // AUTH_12: refresh_token参数不能为空
    MISSING_REFRESH_TOKEN("12", AUTH, "refresh token参数不能为空"),
    // unsupported_response_type:Grant not supported
    // AUTH_13: 不支持的授权类型
    GRANT_NOT_SUPPORTED("13", AUTH, "不支持的授权类型"),
    // invalid_request:Invalid username parameter in request
    // AUTH_14: 无效的username参数
    INVALID_USERNAME_PARAMETER("14", AUTH, "无效的username参数"),
    // invalid_client:No client could be found
    // AUTH_15: 无效的客户端
    NO_CLIENT_COULD_BE_FOUND("15", AUTH, "无效的客户端"),

    // invalid_request:Invalid access token
    // AUTH_16: 无效的access token
    INVALID_ACCESS_TOKEN("16", AUTH, "无效的access token"),

    // invalid_client:Invalid client credentials
    // AUTH_17: 无效的客户端授权
    INVALID_CLIENT_CREDENTIALS("17", AUTH, "无效的客户端授权"),
    // invalid_request:Missing confirm_password parameter in request
    // AUTH_18: 确认密码不为空
    MISSING_CONFIRM_PASSWORD("18", AUTH, "确认密码不为空"),
    // invalid_request:Missing validation_code parameter in request
    // AUTH_19: 手机验证码不为空
    MISSING_VALIDATION_CODE("19", AUTH, "手机验证码不为空"),
    // for resource server, Missing access_token in request header
    // AUTH_20: access_token参数不能为空
    MISSING_ACCESS_TOKEN("20", AUTH, "access token参数不能为空"),
    // invalid_request:access token has expired
    // AUTH_21:access_token已过期
    ACCESS_TOKEN_HAS_EXPIRED("21", AUTH, "access token已过期"),

    INVALID_TICKET("22", AUTH, "无效的ticket值"),

    INVALID_TIMESTAMP("23", AUTH, "无效的timestamp值"),

    INVALID_SIGN("24", AUTH, "无效的签名"),

    INVALID_DATA("25", AUTH, "无效的数据"),

    INVALID_VERSION("26", AUTH, "无效的版本号");

    /**
     * 响应码
     */
    private final String code;

    /**
     * 响应消息
     */
    private final String message;

    /**
     * 构造函数
     *
     * @param code 响应码
     * @param codeSign 响应码标识
     * @param message 消息
     */
    AuthCode(String code, String codeSign, String message) {
        this.code = codeSign + "_" + code;
        this.message = message;
    }

    @Override
    public String code() {
        return code;
    }

    @Override
    public String message() {
        return message;
    }
}
